<template>
    <div class="pageContainer">
        <div class="searchWarp">
            <CRadio title="" v-model="condition.timeType" opType="opTimeType"></CRadio>
            <CDate v-if="condition.timeType == 4" title="开始时间" v-model="condition.startTime"></CDate>
            <CDate v-if="condition.timeType == 4" title="结束时间" v-model="condition.endTime"></CDate>
            <div class="schLine">
                <CBtn @click="search">查询</CBtn>
            </div>
        </div>
        <div class="treeTable">
            <div style="flex:1;">
                <div class="btnWarp">
                </div>
                <div style="width:98%;margin:0px auto">
                    <el-table :data="tableData" border max-height="550" :summary-method="getSummaries"
                        show-summary
                        style="margin-top: 20px">
                        <el-table-column prop="name" label="店铺">
                        </el-table-column>
                        <el-table-column prop="order_no" label="订单编号" width="180">
                        </el-table-column>
                        <el-table-column prop="order_time" label="下单时间">
                        </el-table-column>
                        <el-table-column prop="pay_time" label="支付时间">
                        </el-table-column>
                        <el-table-column prop="pay_total" label="订单金额">
                        </el-table-column>
                        <el-table-column prop="total" label="实付金额">
                        </el-table-column>
                    </el-table>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import pagingMixin from '@/mixin/pagingMixin'
export default {
    mixins: [pagingMixin],
    data() {
        return {
            condition: {
                timeType: 0,
                startTime: '',
                endTime: ''
            },
            tableData: []
        }
    },
    created() {
        
    },
    methods: {
        search() {
            this.$scx.getprorate(this.condition).then(res => {
                console.log(res);
                this.tableData = res.data;
            })
        },
        getSummaries(param) {
            const { columns, data } = param;
            const sums = [];
            console.log(1);
            sums[0] = '合计';
            // console.log(data.map(item => Number(item['pay_total'])));
            sums[1] = "";
            sums[2] = "";
            sums[3] = "";
            
            sums[4] = data.map(item => Number(item['pay_total'])).reduce((prev, curr) => {
                const value = Number(curr);
                if (!isNaN(value)) {
                    return prev + curr;
                } else {
                    return prev;
                }
            }, 0);
            
            sums[5] = data.map(item => Number(item['total'])).reduce((prev, curr) => {
                const value = Number(curr);
                if (!isNaN(value)) {
                    return prev + curr;
                } else {
                    return prev;
                }
            }, 0);
            console.log(sums);
           

            return sums;
        }
    }
}
</script>

<style lang="scss" scoped></style>